// 按需到入defineStore()函数用于创建store
import {defineStore} from "pinia"
//使用defineStore()函数创建一个store
const useCounter = defineStore("counter", {
    actions: {
        incement:function(sum) {
            // this.counter++
            this.counter += sum
        },
        async getData() {
            const res = await fetch("http://123.207.32.32:8080/home/multidata")
            const data = await res.json()
            this.list = data
            return data //返回promise
        }
    },
    state: () => {
        return {
            counter: 0,
            list: ''
        }
    },
    getters: {
        doubleCount: (state) => {
            return state.counter * 2
        }
    }
})
export default useCounter
